Skip to content

Add entangled weave command for transforming Markdown - #103

Merged
jhidding merged 1 commit into
mainfrom
feature/weave
Nov 9, 2026
Merged

jhidding merged 1 commit into
mainfrom
feature/weave

Conversation

@jhidding

@jhidding jhidding commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Addresses #102.

Summary

  • New entangled.weave package with a renderer-agnostic transform API:
    transform_markdown(context, text, *filters, filename=..., reference_map=None) -> Iterator[str],
    plus the generic helpers moved from the mkdocs-plugin (ContentFilter, codeblock_filter, compose_filters, iter_bind).
    The optional reference_map leaves room for project-wide references across pages.
  • New entangled weave [-f filter]... [-o output] [input] command (stdin/stdout by default, label filter by default), with --list-filters.
  • Filters:
    • label: wraps code blocks that have an id or file= in <div class="entangled-code-block" markdown="1"> with a label line. Renders in GitHub, Pandoc and Python-Markdown (md_in_html + attr_list). Known limitation: Python-Markdown doesn't process md_in_html inside list items.
    • title: port of the plugin's add_title, adding a pymdownx-style title attribute; keeps the original fence.
  • Log console now writes to stderr, so weave output on stdout isn't mixed with log messages. This affects all commands.
  • README section "Weaving" and man page entry.

More advanced filters (e.g. REPL output) are left for later.

Test plan

  • uv run pytest (82 passed, 6 new in test/weave/test_weave.py)
  • mypy and pyright clean on the new modules
  • Manually rendered woven test/data/hello-world/hello-world.md with Pandoc and Python-Markdown

🤖 Generated with Claude Code

Adds a renderer-agnostic Markdown transform API in `entangled.weave`
(`transform_markdown`, `ContentFilter`, `codeblock_filter`,
`compose_filters`) and an `entangled weave` command exposing it, with
`--list-filters` and two filters:

- `label`: wrap named code blocks in a labelled `<div>`, rendering in
  most Markdown previews.
- `title`: add a pymdownx-style `title` attribute to the code block
  header (port of the mkdocs-plugin's `add_title`).

Logging now goes to stderr so that `weave` output on stdout is clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jhidding
jhidding merged commit f7a9ed8 into main Nov 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant